<template>
	<view class="tabs-box">
		<text v-for="(item, index) in tabList" :key="index" @tap="tabClick" :data-index="index" :class="'tabs-head ' + (item[2]?'active':'')"
		 :url="item[1]" redirect hover-class="className">{{item[0]}}</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {};
		},

		components: {},
		props: {
			tabList: {
				type: Array,
				default: [
					["招工", "", true],
					["找活", "", false]
				] //["人脉集市", "", true], 

			},
		},
		mounted: function() {},
		methods: {
			tabClick(e) {
				const current = e.currentTarget.dataset.index;
				let list = this.tabList; // 设置Tab数据

				for (var i = 0; i < list.length; i++) {
					if (i == current) {
						list[i][2] = true;
					} else {
						list[i][2] = false;
					}
				}

				this.$emit("setSwipterData", {
					detail: current
				}); // 赋值数据
				this.setData({
					tabList: list
				});
			}

		}
	};
</script>
<style>
	.tabs-box {
		display: flex;
		height: 100rpx;
		margin-bottom: 10rpx;
		background: #fff;
	}

	.tabs-head {
		width: 50%;
		height: 100%;
		text-align: center;
		line-height: 100rpx;
	}

	.active {
		border-bottom: 1px #19a918 solid;
		color: #19a918;
	}
</style>
